package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.pasture.PastureConfig;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.manger.activity.pasture.PastureMgr;

import java.util.ArrayList;

public class PastureRecyleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        PastureConfig config = PastureMgr.getConfig();
        if (config != null) {
            ActivityInfo activityInfo = config.getActivityInfo();
            if (activityInfo != null) {
                long recycleTime = activityInfo.getEndTime() * 1000L + 600 * 1000;
                ActivityItemRecycleMgr.addRecycleItemData(config.getPastureEnergyItemId(), activityType, 1, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(config.getPastureSkillItemId(), activityType, 1, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(config.getPastureUpgradeItemId(), activityType, 1, recycleTime, new ArrayList<>());
                ActivityItemRecycleMgr.addRecycleItemData(config.getPastureRestartItemId(), activityType, 1, recycleTime, new ArrayList<>());
            }
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.Pasture.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        UserBagItem item = getUserBagItem(userId, data.getItemId());
        if (item != null && item.getNum() > 0) {
            removeItem(item);
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
